<?php

/**
 * Facultad form base class.
 *
 * @method Facultad getObject() Returns the current form's model object
 *
 * @package    sibi-salud
 * @subpackage form
 * @author     SIBI <sibiud@gmail.com>
 */
abstract class BaseFacultadForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'       => new sfWidgetFormInputHidden(),
      'nombre'   => new sfWidgetFormInputText(),
      'telefono' => new sfWidgetFormInputText(),
      'pagina'   => new sfWidgetFormInputText(),
      'correo'   => new sfWidgetFormInputText(),
      'sede_id'  => new sfWidgetFormPropelChoice(array('model' => 'Sede', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'id'       => new sfValidatorPropelChoice(array('model' => 'Facultad', 'column' => 'id', 'required' => false)),
      'nombre'   => new sfValidatorString(array('max_length' => 45)),
      'telefono' => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'pagina'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'correo'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'sede_id'  => new sfValidatorPropelChoice(array('model' => 'Sede', 'column' => 'id', 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'Facultad', 'column' => array('nombre'))),
        new sfValidatorPropelUnique(array('model' => 'Facultad', 'column' => array('telefono'))),
      ))
    );

    $this->widgetSchema->setNameFormat('facultad[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Facultad';
  }


}
